#!/usr/bin/env python3
"""
跨平台批量构建脚本
可以在不同平台上构建所有目标版本
"""

import os
import sys
import platform
from build_nuitka import NuitkaBuilder, debug_print


class MultiPlatformBuilder:
    """多平台构建器"""
    
    def __init__(self):
        self.targets = [
            {"platform": "windows", "arch": "x86_64"},
            {"platform": "linux", "arch": "x86_64"},
            {"platform": "darwin", "arch": "x86_64"},
        ]
    
    def build_for_platform(self, target_platform, target_arch):
        """为特定平台构建"""
        current_platform = platform.system().lower()
        
        if current_platform != target_platform:
            debug_print(f"跳过 {target_platform}/{target_arch} (当前平台: {current_platform})")
            return False
        
        debug_print(f"开始构建 {target_platform}/{target_arch} 版本...")
        
        # 这里可以添加交叉编译逻辑
        # 目前只构建当前平台版本
        builder = NuitkaBuilder()
        builder.build()
        
        return True
    
    def build_all(self):
        """构建所有目标平台"""
        debug_print("开始多平台构建...")
        
        successes = 0
        for target in self.targets:
            try:
                if self.build_for_platform(target["platform"], target["arch"]):
                    successes += 1
            except Exception as e:
                debug_print(f"构建 {target['platform']} 失败: {e}")
        
        debug_print(f"构建完成! 成功: {successes}/{len(self.targets)}")
        
        if successes == 0:
            debug_print("⚠️  没有构建任何平台版本")
        elif successes < len(self.targets):
            debug_print("ℹ️  部分平台构建失败")


def main():
    """主函数"""
    builder = MultiPlatformBuilder()
    builder.build_all()


if __name__ == "__main__":
    main()